package com.ruoyi.project.module.remark.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.remark.domain.Remark;
import com.ruoyi.project.module.remark.service.IRemarkService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 补全与说明 信息操作处理
 * 
 * @author ruoyi
 * @date 2018-12-14
 */
@Controller
@RequestMapping("/module/remark")
public class RemarkController extends BaseController
{
    private String prefix = "module/remark";
	
	@Autowired
	private IRemarkService remarkService;
	
	@RequiresPermissions("module:remark:view")
	@GetMapping()
	public String remark()
	{
	    return prefix + "/remark";
	}
	
	/**
	 * 查询补全与说明列表
	 */
	@RequiresPermissions("module:remark:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Remark remark)
	{
		startPage();
        List<Remark> list = remarkService.selectRemarkList(remark);
		return getDataTable(list);
	}
	
	/**
	 * 新增补全与说明
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存补全与说明
	 */
	@RequiresPermissions("module:remark:add")
	@Log(title = "补全与说明", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Remark remark)
	{		
		return toAjax(remarkService.insertRemark(remark));
	}

	/**
	 * 修改补全与说明
	 */
	@GetMapping("/edit/{completeRemarkId}")
	public String edit(@PathVariable("completeRemarkId") Long completeRemarkId, ModelMap mmap)
	{
		Remark remark = remarkService.selectRemarkById(completeRemarkId);
		mmap.put("remark", remark);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存补全与说明
	 */
	@RequiresPermissions("module:remark:edit")
	@Log(title = "补全与说明", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Remark remark)
	{		
		return toAjax(remarkService.updateRemark(remark));
	}
	
	/**
	 * 删除补全与说明
	 */
	@RequiresPermissions("module:remark:remove")
	@Log(title = "补全与说明", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(remarkService.deleteRemarkByIds(ids));
	}
	
}
